package com.cuij.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cuij.entity.Result;
import com.cuij.service.orderGoodsService;

@Controller
@RequestMapping("/goods")
public class orderGoodsController {

    @Resource
    private orderGoodsService ordergoodsservice;

    /**
     * 增加新的菜品
     * 
     * @param use_name
     * @param goods_name
     * @param goods_desc
     * @param goods_pic
     * @param goods_price
     * @return
     * @throws Exception
     */
    @RequestMapping("/goodsadd.do")
    @ResponseBody
    public Result addGoodsExecute(String busi_id, String goods_name, String goods_desc, String goods_pic,
            double goods_price) throws Exception {
        Result result = ordergoodsservice.goodsadd(busi_id, goods_name, goods_desc, goods_pic, goods_price);
        return result;

    }

    /**
     * 按默认方式查询
     * 
     * @param busi_id
     * @return
     * @throws Exception
     */
    @RequestMapping("/querygoods.do")
    @ResponseBody
    public Result queryGoodsExecute(String busi_id) throws Exception {
        Result result = ordergoodsservice.querygoods(busi_id);
        return result;

    }

    // 查询单条数据
    @RequestMapping("/querysimplegoods.do")
    @ResponseBody
    public Result simpleGoodsExecute(String goods_id) throws Exception {
        Result result = ordergoodsservice.querysimplegoods(goods_id);
        return result;

    }

    // 删除商品
    @RequestMapping("/deletegoods.do")
    @ResponseBody
    public Result deleteGoodsExecute(String goods_id) throws Exception {
        Result result = ordergoodsservice.deletegoods(goods_id);
        return result;
    }

    // 修改单产品信息
    @RequestMapping("/modifygoods.do")
    @ResponseBody
    public Result modifyGoodsExecute(String goods_id, String goods_name, String goods_desc, String goods_pic,
            double goods_price, String oldfilename) throws Exception {
        Result result = ordergoodsservice.modifygoods(goods_id, goods_name, goods_desc, goods_pic, goods_price,
                oldfilename);
        return result;
    }

    // 按不同条件查询商品信息
    @RequestMapping("/querygoodsorderby.do")
    @ResponseBody
    public Result queryGoodsOrderByExecute(String busi_id, String condition) {
        Result result = ordergoodsservice.querygoodsorderby(busi_id, condition);
        return result;
    }
}
